<template>
	<div class="posa">
		<div class="statibox-index">
			<span v-for="(item,index) in tabJson.tabbox" :class="{on:index==tabJson.tabboxIndex}" @click="onTabboxChange(index)" >{{item.name}}</span>				
		</div>
		<div class="statibox-section">
			<table>
				<tr>
					<th>{{tabJson.tabbox[tabJson.tabboxIndex].name}}</th>
					<th>数量</th>
					<th>占比</th>
				</tr>
				<!--tr开始循环-->
				<tr v-for="item in datas">
					<td><span v-if="tabJson.tabboxIndex == 0">{{item.channelName}}</span><span v-else>{{item.followerName}}</span></td>
					<td>{{item.customerNum}}</td>
					<td>0%</td>
				</tr>				
			</table>
		</div>
	</div>
</template>
<script>
	export default{		
		data(){
			return {
				//结构品牌列表
			    tabJson:{
			    	tabbox:[
			    		{
			    			name:'来源',
			    			getUrl:'CHANNEL_ID',			    			
			    			getJson:[]
			    		},
			    		{
			    			name:'销售',
			    			getUrl:'FOLLOWER_ID',				    			
			    			getJson:[]
			    		},			    		
				    ],
				    tabboxIndex:0,
			    },
			    datas:[],
			    params:{
			    	params:{}
			    }
			}
		},
		methods:{
			onTabboxChange(e){
				this.tabJson.tabboxIndex = e
				this.dataGetJson(e)
			},
			//请求接口数据
			dataGetJson(e){
				let searchType
				switch(~~this.params.params.statisType){
					case 10:
						searchType = 'followUpInfo'
						break
					case 20:
						searchType = 'orderUpInfo'
						break
					case 50:
						searchType = 'fixtureInfo'
						break
					default:
						break
				}
				axios.get(baseUrl+'/crm-web/controller/resForApp/countFollowInfo',{params:{
					followState:this.params.params.statisType,
					queryDate:this.params.params.startDate,
					searchMode:this.tabJson.tabbox[e].getUrl,
					shopId:this.params.params.shopId,
					searchType:searchType,
				}}).then(res=>{
					this.datas = res.data.result
				})
			},
			queryRouter() {
				//console.log(this.$route.query)
				if(this.$route.query.time) {
					this.params.params.month = this.$route.query.time
					this.params.params.startDate = ''
				}
				if(this.$route.query.timeDay) {
					this.params.params.startDate = this.$route.query.timeDay
					this.params.params.month = ''
				}
				this.params.params.shopId = this.$route.query.shopId
				this.params.params.marketId = this.$route.query.marketId
				this.params.params.statisType = this.$route.query.typeId
			},
			//请求成功后执行
			seccessFn(res){
				var successData = res.data.result
				this.datas = successData
			},
		},
		mounted:function(){
			this.queryRouter()
			setTimeout(()=>{
				this.dataGetJson(0)
			},20)
		},
		
		activated:function(){			
			this.$emit('tabMenuChange',0)
		},
	}
</script>